<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function find(arr) {
      const map = new Map();
      for (const item of arr) {
        map.set(item, map.get(item) ? map.get(item) + 1 : 1);
      }
      return Array.from(map).sort((a, b) => b[1] - a[1])[0][0];
    };
    console.log(find([1, 2, 3, 4, 5]));
  </script>
</body>

</html>